<script src="../../resources/dump-as-markup.js"></script>
<p>This tests removing style after removing CSS property. Undo should bring back the CSS property we removed.</p>
<div id="test" contenteditable><span style="font-weight: 900;">test</span></div>
<script>

Markup.description('This tests removing style after removing CSS property. Undo should bring back the CSS property we removed.');

Markup.dump('test', 'Initially "test" should be bold wrapped with a span');
window.getSelection().selectAllChildren(test);
document.execCommand('bold', false, null);
Markup.dump('test', 'Unbolding should remove the CSS style and also remove the span');

document.execCommand('undo', false, null);
Markup.dump('test', 'Undo should bring back both the span and style so that "test" is once again bold');

document.execCommand('redo', false, null);
Markup.dump('test', 'Redo should unbold "test" and there should be no span');

document.execCommand('undo', false, null);
Markup.dump('test', 'Undo once more');

document.getElementById('test').innerHTML = '<span style="font-weight: 900;">test</span>';
var span = document.getElementById('test').firstChild;
span.id = 'test_span';
span.title = 'hello, world';
window.getSelection().selectAllChildren(test);
Markup.dump('test', 'Reset, and added id and title');

document.execCommand('bold', false, null);
Markup.dump('test', 'Unbolding should remove the CSS style but shouldn\'t remove the span');

document.execCommand('undo', false, null);
Markup.dump('test', 'Undo should restore the style and "test" should be bold');

document.execCommand('redo', false, null);
Markup.dump('test', 'Redo should remove the style again');

document.getElementById('test').innerHTML = '<span style="font-weight: 900;">test</span>';
var span = document.getElementById('test').firstChild;
span.style.color = 'blue';
window.getSelection().selectAllChildren(test);
Markup.dump('test', 'Reset, and added color:blue');

document.execCommand('bold', false, null);
Markup.dump('test', 'Unbolding should remove the font-weight but shouldn\'t remove the style ');

document.execCommand('undo', false, null);
Markup.dump('test', 'Undo should reset the style so that "test" is both bold and blue');

document.execCommand('redo', false, null);
Markup.dump('test', 'Redo should only remove font-weight and leave "test" blue');

document.execCommand('foreColor', false, "#000000");
Markup.dump('test', 'Setting the forecolor to black should remove both the style and the span');

document.execCommand('undo', false, null);
Markup.dump('test', 'Undo should make "test" blue again');

</script>
